package com.zxp.snowy.test.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;

import com.zxp.snowy.test.entity.Simple;
import com.zxp.snowy.test.param.SimpleParam;
import com.zxp.snowy.test.service.SimpleService;

import lombok.extern.slf4j.Slf4j;
import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.annotion.Permission;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import vip.xiaonuo.core.pojo.page.PageResult;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
/**
 * <p>
 * 测试表 前端控制器
 * </p>
 *
 * @author shollin
 * @since 2024-09-11
 */
@Controller
@RequestMapping("/simple")
public class SimpleController {
    private String PATH_PREFIX = "simple/";

    @Resource
    private SimpleService simpleService;

    /**
     * 测试表页面
     *
     * @author shollin
     * @date 2024-09-11
     */
    @Permission
    @GetMapping("/simple/index")
    public String index() {
        return PATH_PREFIX + "index.html";
    }

    /**
     * 测试表表单页面
     *
     * @author shollin
     * @date 2024-09-11
     */
    @GetMapping("/simple/form")
    public String form() {
        return PATH_PREFIX + "form.html";
    }

    /**
     * 查询测试表
     *
     * @author shollin
     * @date 2024-09-11
     */
    @Permission
    @ResponseBody
    @GetMapping("/simple/page")
    @BusinessLog(title = "测试表_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public PageResult<Simple> page(SimpleParam simpleParam) {
        return simpleService.page(simpleParam);
    }

    /**
     * 添加测试表
     *
     * @author shollin
     * @date 2024-09-11
     */
    @Permission
    @ResponseBody
    @PostMapping("/simple/add")
    @BusinessLog(title = "测试表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(SimpleParam.add.class) SimpleParam simpleParam) {
            simpleService.add(simpleParam);
        return new SuccessResponseData();
    }

    /**
     * 删除测试表
     *
     * @author shollin
     * @date 2024-09-11
     */
    @Permission
    @ResponseBody
    @PostMapping("/simple/delete")
    @BusinessLog(title = "测试表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(SimpleParam.delete.class) List<SimpleParam> simpleParamList) {
            simpleService.delete(simpleParamList);
        return new SuccessResponseData();
    }

    /**
     * 编辑测试表
     *
     * @author shollin
     * @date 2024-09-11
     */
    @Permission
    @ResponseBody
    @PostMapping("/simple/edit")
    @BusinessLog(title = "测试表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(SimpleParam.edit.class) SimpleParam simpleParam) {
            simpleService.edit(simpleParam);
        return new SuccessResponseData();
    }

    /**
     * 查看测试表
     *
     * @author shollin
     * @date 2024-09-11
     */
    @Permission
    @ResponseBody
    @GetMapping("/simple/detail")
    @BusinessLog(title = "测试表_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(SimpleParam.detail.class) SimpleParam simpleParam) {
        return new SuccessResponseData(simpleService.detail(simpleParam));
    }

    /**
     * 测试表列表
     * @author shollin
     * @date 2024-09-11
     */
    @Permission
    @ResponseBody
    @GetMapping("/simple/list")
    @BusinessLog(title = "测试表_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(SimpleParam simpleParam) {
        return new SuccessResponseData(simpleService.list(simpleParam));
    }
}
